const dbName = 'money'
const dbPath = '_doc/moneyMange.db'

export default{
	createDatabase(){
		console.log("进入创建table方法");
		let isOpen = plus.sqlite.isOpenDatabase({
			name:dbName,
			path:dbPath
		});
		if(isOpen){
			return Promise.resolve();
		}
		return new Promise((resolve,reject)=>{
			plus.sqlite.openDatabase({
				name:dbName,
				path:dbPath,
				success:resolve,
				fail:reject
			});
		});
	},
	
	selectSql(sql){
		console.log('查询',sql);
		return new Promise((resolve,reject)=>{
			plus.sqlite.selectSql({
				name:dbName,
				sql,
				success:resolve,
				fail:reject
			});
		});
	},
	
	executeSql(sql){
		console.log('执行',sql);
		return new Promise((resolve,reject)=>{
			plus.sqlite.executeSql({
				name:dbName,
				sql,
				success:resolve,
				fail:reject
			});
		});
	}
}